package com.jin.webvideo.controller;

import com.jin.webvideo.service.RefreshService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private EhCacheCacheManager ehCacheCacheManager;
    @Autowired
    private RefreshService refreshService;
    @ResponseBody
    @GetMapping("/ehcache/reload")
    public String reloadCache(@RequestParam(name = "name", required = false ,defaultValue = "configCache") String name){
        ehCacheCacheManager.getCache(name).clear();
        return "SUCCESS";
    }

    @ResponseBody
    @GetMapping("/refresh/access")
    public String ref() {
        return refreshService.accessControl();
    }
}
